package demo03;

/**
 * 1.this 关键字
 * 类中this指本身
 * this可以调用属性和方法
 * 2.static 关键字
 * 静态属性 一个地方修改类中改静态属性 其他类的对象跟着变化
 */

public class Demo03 {
    class Student {
        String id;
        private String name;
        private int age;
        private int gender;
        public String dep = "信息工程系";
        public static String hobby = "健身";

        public Student() {

        }

        public Student(String ID) {

            id = ID;

        }

        public Student(String ID, String n) {
            id = ID;
            name = n;
        }

        public static setName(String s) {

            this.name = name;

        }

        public static getName() {
            return name;
        }

        public void setAge(int age) {
            if (a < 0 || a > 150) {
                System.out.println("输入年龄非法")
            } else {
                this.age = age;
            }
        }

        public void setGender(String g) {
            if (g.equals("男")) {
                gender = 0;
            } else {
                gender = 1;
            }
        }

        public String getGender() {
            if (gender == 0) {
                return "男";
            } else {
                return "女";
            }
        }
    }
    public class Deno03{
        public static void main(String[] args) {
            Student stu1 = new Student();
            stu1.setName("朱小明");
            stu1.setAge(20);
            System.out.println(stu1.dep);
            Student stu2 = new Student();
            System.out.println(stu2.dep);w
            System.out.println("***********");
            stu1.dep="宇宙系";
            System.out.println(stu1.dep);
            System.out.println(stu2.dep);
            System.out.println("查看爱好");
            System.out.println("stu1.hobby");
            System.out.println("stu1.hobby");
            System.out.println("***********");
            stu2.hobby="抽烟";
            System.out.println("stu1.hobby");
            System.out.println("stu1.hobby");
        }
    }

